<?php 
	header("content-type:text/html;charset=utf-8");
	$redis = new Redis();
	$redis->conncent("127.0.0.1","6379");
	$goods_id = $_POST['goods_id'];
	$pdo = new PDO("mysql:host=127.0.0.1;dbname=goods","root","root");
	$res = $pdo->query($sql)->fetch();
	if($redis->lpop("data".$goods_id)){
		$sql = "update hotgoods set number = number-1 where goods_id=$goods_id";
		$info = $pdo->exec($sql);
		if($info){
			$data = array('code'=>1,"msg"=>"抢购成功");
		}else{
			$data = array('code'=>0,"msg"=>"恭喜你，抢购成功了")；
		}
	}
	echo json_encode($data);
 ?>